package library;

import java.time.LocalDateTime;
import java.util.Random;
import java.util.Scanner;

public class BookStore {
	static Book[] books=new Book[6];
	static{
		books[0]=new Book(1,"java程序设计",50,10);
		books[1]=new Book(2,"C++",40,10);
		books[2]=new Book(3,"PHP",30,10);
		books[3]=new Book(4,"Python",20,10);
		books[4]=new Book(5,"web",20,10);
		books[5]=new Book(6,"mysql",20,10);
	}
	public static void main(String[] args) {

		show(books);

		Person p=new Person("张三");
		Book book = p.buy(books);
		//System.out.println(book.getId()+book.getName());

		count(p,book);
		
	}
	
	public static void show(Book[] books){
		System.out.println("图书编号\\t图书价格\\t库存\\t价格");
		for(int i=0;i<books.length;i++){
			System.out.println(books[i].getId()+"\t"+books[i].getName()+"\t"+books[i].getPrice()+"\t"+books[i].getStorage());
		}
	}

	public static void count(Person p,Book book){
		System.out.println("请输入购书的数量");
		Scanner sc=new Scanner(System.in);
		int number = sc.nextInt();
		//[0,10)
		Random random=new Random();
		int orderNum=random.nextInt();

		System.out.println("订单编号:"+Math.abs(orderNum));

		System.out.println("购物时间:"+LocalDateTime.now());
		System.out.println("会员:"+p.getName());
		System.out.println("图书名称"+book.getName()+",单价"+book.getPrice()+"￥,购买数量"+number);
		System.out.println("-----------总计:"+book.getPrice()*number);
	}
}
